import { createRequestTypes } from '@UTILS/reduxHelper'
import {
  AddressActionITF,
  AddressCreateActionITF,
  AddressDeleteActionITF, AddressSetActionITF,
  AddressUpdateActionITF, CreateAddressITF,
  UpdateAddressITF
} from '@REDUXITF/address'
import { ShipAddressITF } from '@INTERFACES/Address'
export const GET_SHIP_ADDRESS = createRequestTypes('GET_SHIP_ADDRESS')
export const CREATE_SHIP_ADDRESS = createRequestTypes('CREATE_SHIP_ADDRESS')
export const UPDATE_SHIP_ADDRESS = createRequestTypes('UPDATE_SHIP_ADDRESS')
export const DELETE_SHIP_ADDRESS = createRequestTypes('DELETE_SHIP_ADDRESS')
export const SET_SHIP_ADDRESS = createRequestTypes('SET_SHIP_ADDRESS')

export default {
  dispatchGetShipAddress(isInit: boolean, isSetDefaultAddress?: boolean): AddressActionITF {
    return {
      type: GET_SHIP_ADDRESS.REQUEST,
      isInit,
      isSetDefaultAddress
    }
  },
  dispatchCreateAddress(address: CreateAddressITF, isSelected: boolean): AddressCreateActionITF {
    return {
      type: CREATE_SHIP_ADDRESS.REQUEST,
      address,
      isSelected
    }
  },
  dispatchUpdateAddress(address: UpdateAddressITF): AddressUpdateActionITF {
    return {
      type: UPDATE_SHIP_ADDRESS.REQUEST,
      address
    }
  },
  dispatchDeleteAddress(p8Id: string): AddressDeleteActionITF {
    return {
      type: DELETE_SHIP_ADDRESS.REQUEST,
      p8Id
    }
  },
  dispatchSetAddress(address: ShipAddressITF | null): AddressSetActionITF {
    return {
      type: SET_SHIP_ADDRESS.REQUEST,
      address
    }
  }
}
